package com.daedalus.klasaObjekte.data;
/*
 * Created with IntelliJ IDEA.
 * Author: Kostika Gorica
 * Date: 12-11-06
 * Time: 11.05.MD
 */

public class DataSipasInes {
    int viti;
    int muaji;
    int dita;

    private int[] nrDiteMuaji = {0,31,28,31,30,31,30,31,31,30,31,30,31};

    public DataSipasInes(int viti, int muaji, int dita) {
        this.viti = viti;
        this.muaji = muaji;
        this.dita = dita;
    }

    public void shtoDite(int nrDite){
        while (dita+nrDite>nrDiteMuaji[muaji]){
            int deriNeFundMuaji=nrDiteMuaji[muaji];
            if (muaji == 12){
                viti++;
                muaji=1;
            } else
                muaji++;

            nrDite -= deriNeFundMuaji;

        }
        dita += nrDite;
    }

    public void shtoJave(int nrJave){
        shtoDite(nrJave*7);
    }

    public int getViti() {
        return viti;
    }

    public int getMuaji() {
        return muaji;
    }

    public int getDita() {
        return dita;
    }

    public int nrDite(Data data){
        int diff=0;
        Data temp = new Data(getViti(),getMuaji(),getDita());
        while (temp.getDita()!=data.getDita() || temp.getMuaji() != data.getMuaji() || temp.getViti()!=data.getViti()){
            temp.shtoDite(1);
            diff++;
        }
        return diff;
    }

    public String toString(){
        return String.format("%d/%d/%d", getDita(),getMuaji(),getViti());
    }
}
